bitkeeper revision 1.1094.1.1 (40f79e49R1DHspwInBVx1sG5QTUSmA)
authortw275@labyrinth.cl.cam.ac.uk <tw275@labyrinth.cl.cam.ac.uk>
Fri, 16 Jul 2004 09:22:17 +0000 (09:22 +0000)
committertw275@labyrinth.cl.cam.ac.uk <tw275@labyrinth.cl.cam.ac.uk>
Fri, 16 Jul 2004 09:22:17 +0000 (09:22 +0000)
Added logging of uptime of domains - needs to be made persistent

BitKeeper/etc/logging_ok
tools/python/xen/xend/XendDomainInfo.py

index 34d574e882be97f5e5092ef5b30f13617d8f4dd4..82e28a36525594d6aa21866543a9fc693c3bceb1 100644 (file)
@@ -41,5 +41,6 @@ smh22@uridium.cl.cam.ac.uk
 sos22@labyrinth.cl.cam.ac.uk
 tlh20@elite.cl.cam.ac.uk
 tlh20@labyrinth.cl.cam.ac.uk
+tw275@labyrinth.cl.cam.ac.uk
 tw275@striker.cl.cam.ac.uk
 xenbk@gandalf.hpl.hp.com
index 5b6677b1978057f0c89aa92efd1681356e1756c7..3ac2d1038107589349c769ca01f98620fd92e6c8 100644 (file)
@@ -13,6 +13,7 @@ import types
 import re
 import sys
 import os
+import time
 
 from twisted.internet import defer
 #defer.Deferred.debug = 1
@@ -331,6 +332,7 @@ class XendDomainInfo:
         self.config = None
         self.id = None
         self.dom = None
+        self.startTime = None
         self.name = None
         self.memory = None
         self.image = None
@@ -354,7 +356,7 @@ class XendDomainInfo:
     def setdom(self, dom):
         self.dom = int(dom)
         self.id = str(dom)
-        
+    
     def update(self, info):
         """Update with  info from xc.domain_getinfo().
         """
@@ -392,7 +394,13 @@ class XendDomainInfo:
                 reason = shutdown_reason(self.info['shutdown_reason'])
                 sxpr.append(['shutdown_reason', reason])
             sxpr.append(['cpu', self.info['cpu']])
-            sxpr.append(['cpu_time', self.info['cpu_time']/1e9])
+            sxpr.append(['cpu_time', self.info['cpu_time']/1e9])    
+            
+            if self.startTime:
+                upTime =  time.time() - self.startTime  
+                sxpr.append(['up_time', str( upTime ) ] )
+                sxpr.append(['start_time', str( self.startTime ) ] )
+
         if self.console:
             sxpr.append(self.console.sxpr())
         if self.config:
@@ -409,6 +417,10 @@ class XendDomainInfo:
             self.memory = int(sxp.child_value(config, 'memory'))
             if self.memory is None:
                 raise VmError('missing memory size')
+
+            if sxp.child_value( config, 'start_time' ) != None:
+                self.startTime = float( sxp.child_value( config, 'start_time' ) )
+
             self.configure_console()
             self.configure_restart()
             self.configure_backends()
@@ -586,6 +598,9 @@ class XendDomainInfo:
                           % (name, memory))
         self.setdom(dom)
 
+        if self.startTime == None:
+            self.startTime = time.time()
+
     def build_domain(self, ostype, kernel, ramdisk, cmdline, vifs_n):
         """Build the domain boot image.
         """